package p100;

public class Leetcode_198 {

    public int rob(int[] nums) {
        if (nums.length == 0) {
            return 0;
        }
        int tmp1 = 0, tmp2 = nums[0];
        for (int i = 1; i < nums.length; i++) {
            int tmp = Math.max(tmp2, tmp1 + nums[i]);
            tmp1 = tmp2;
            tmp2 = tmp;
        }
        return tmp2;
    }

    public static void main(String[] args) {
        Leetcode_198 l = new Leetcode_198();
        System.out.println(l.rob(new int[]{1, 1}));
    }
}
